using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Scene;
using MicroMsg.Storage;
using System;
using System.Collections.ObjectModel;
namespace MicroMsg.Manager
{
	public class SessionMgr
	{
		private enum Session_Load_State
		{
			UnLoaded,
			Loading,
			Loaded
		}
		public ObservableCollection<Conversation> SessionListItems;
		private static SessionMgr.Session_Load_State mLoadState;
		public SessionMgr()
		{
			EventWatcher eventWatcher = new EventWatcher(this, null, new EventHandlerDelegate(this.on_Stg_Contact_Mod_EventHandler));
			EventCenter.registerEventWatcher(EventConst.ON_STG_CONTACT_MOD, eventWatcher);
			EventWatcher eventWatcher2 = new EventWatcher(this, null, new EventHandlerDelegate(this.on_Stg_Contact_Add_EventHandler));
			EventCenter.registerEventWatcher(EventConst.ON_STG_CONTACT_ADD, eventWatcher2);
		}
		public void LoadSessionOnlyOnce()
		{
			if (SessionMgr.mLoadState != SessionMgr.Session_Load_State.UnLoaded)
			{
				return;
			}
			SessionMgr.mLoadState = SessionMgr.Session_Load_State.Loading;
			ServiceCenter.asyncExec(delegate
			{
				this.SessionListItems = ServiceCenter.conversationMgr.getList();
				SessionMgr.mLoadState = SessionMgr.Session_Load_State.Loaded;
				EventCenter.postEvent(EventConst.ON_UI_SESSION_LOADED, this.SessionListItems, null);
				Log.smethod_5(base.GetType().get_Name(), "postEvent:ON_UI_SESSION_LOADED");
			});
		}
		public void InsertTestSessionData()
		{
			for (int i = 0; i < 4; i++)
			{
				for (int j = 0; j < 6; j++)
				{
					Conversation conversation = new Conversation();
					conversation.nIsSend = j % 2;
					conversation.nStatus = 2;
					if (j == 3)
					{
						conversation.nUnReadCount = j;
					}
					else
					{
						conversation.nUnReadCount = 0;
					}
					if (j == 4)
					{
						conversation.strMsgType = "34";
					}
					else
					{
						conversation.strMsgType = string.Concat(j);
					}
					if (j == 0)
					{
						conversation.nTime = Util.Tick2ms(DateTime.get_Now().AddYears(-2).get_Ticks());
						conversation.strUsrName = "好友推荐消息" + i;
						conversation.strContent = "随心加入了微信";
					}
					else
					{
						if (j == 1)
						{
							conversation.nTime = Util.Tick2ms(DateTime.get_Now().AddMonths(-2).get_Ticks());
							conversation.strUsrName = "Andrew" + i;
							conversation.strContent = "打球去!";
						}
						else
						{
							if (j == 2)
							{
								conversation.nTime = Util.Tick2ms(DateTime.get_Now().AddDays(-3.0).get_Ticks());
								conversation.strUsrName = "Austin" + i;
								conversation.strContent = "今天不想回家";
							}
							else
							{
								if (j == 3)
								{
									conversation.nTime = Util.Tick2ms(DateTime.get_Now().AddHours(-3.0).get_Ticks());
									conversation.strUsrName = "16Candles" + i;
									conversation.strContent = "周五有人约你没?";
								}
								else
								{
									if (j == 4)
									{
										conversation.nTime = Util.Tick2ms(DateTime.get_Now().AddMinutes(-3.0).get_Ticks());
										conversation.strUsrName = "古怪的人" + i;
										conversation.strContent = "最讨厌你了";
									}
									else
									{
										if (j == 5)
										{
											conversation.nTime = Util.Tick2ms(DateTime.get_Now().AddMilliseconds(-100.0).get_Ticks());
											conversation.strUsrName = "我不是一个笑话" + i;
											conversation.strContent = "哥给你讲个笑话,从前...";
										}
									}
								}
							}
						}
					}
					StorageMgr.converation.vmethod_0(conversation);
				}
			}
		}
		private void on_Stg_Contact_Mod_EventHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
		}
		private void on_Stg_Contact_Add_EventHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
		}
	}
}
